package org.wattdepot.cli.command;

import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import javax.xml.datatype.XMLGregorianCalendar;
import org.junit.Test;
import org.wattdepot.cli.processor.CommandLineInterface;
import org.wattdepot.util.tstamp.Tstamp;

/**
 * Class for testing TotalGenerated.
 * 
 * @author Remy Baumgarten
 * @author Kevin Chiogioji
 * 
 */
public class TestTotalGenerated extends CommandLineInterface {

  /**
   * Tests Total Generated output against Client output.
   * 
   * @throws Exception -
   */
  @Test
  public void congruenceTest() throws Exception {
    XMLGregorianCalendar startTime = Tstamp.makeTimestamp("2009-10-31");
    XMLGregorianCalendar endTime = Tstamp.incrementDays(startTime, 1);
    TotalGenerated total = new TotalGenerated();
    List<String> args = new ArrayList<String>();
    args.add("energy");
    args.add("SIM_KAHE_2");
    args.add("2009-10-31");
    args.add("60");
    Double classResult = Double.parseDouble(total.doCommand(args));
    Double clientResult = client.getEnergyGenerated("SIM_KAHE_2", startTime, endTime, 60);
    assertEquals("Checking output of Total ", classResult, clientResult);
  }

  /**
   * Test input validation.
   * 
   * @throws Exception -
   */
  @Test
  public void inputValidation() throws Exception {
    TotalGenerated total = new TotalGenerated();
    List<String> args = new ArrayList<String>();
    args.add("fakevalue");
    args.add("SIM_KAHE_2");
    args.add("2009-10-31");
    args.add("60");
    assertEquals("Checking for invalid source ", total.doCommand(args), "Invalid Command");
  }
}
